package com.wzdigit.wms.hm.common.enums;

import java.util.*;

/**
 * 事务类型
 */
public enum OpCodeEnum implements BaseEnum {
    CREATE("Create", "建档", "建档"),
    RECEIVE("Receive", "收货", "收货"),
    STACKING("Stacking", "码盘", "码盘"),
    CANCELSTACKING("CancelStacking", "取消码盘", "取消码盘"),
    PUTON("PutOn", "上架", "上架"),
    PUTOFF("PutOff", "下架", "下架"),
    INSPECT("Inspect", "送检", "送检"),
    INSPECTIONRESULT("InspectionResult", "判检", "判检"),
    PICK("Pick", "拣选", "拣选"),
    RECHECK("ReCheck", "复核", "复核"),
    SHIPPED("Shipped", "出库", "出库"),
    RETURN("Return", "退库", "退库"),
    CONTAINERLOAD("ContainerLoad", "装柜", "装柜"),
    CONTAINERUNLOAD("ContainerUnLoad", "卸柜", "卸柜"),
    TRUCKLOAD("TruckLoad", "装车", "装车"),
    SPLIT("Split", "拆包", "拆包"),
    MERGE("Merge", "并包", "并包"),
    MOVEON("MoveOn", "移库上架", "移库上架"),
    MOVEOFF("MoveOff", "移库下架", "移库下架"),
    ATTRCHANGE("AttrChange", "属性变更", "属性变更"),
    TRANSFEROUT("TransferOut", "调拨出库", "调拨出库"),
    TRANSFERIN("TransferIn", "调拨入库", "调拨入库"),
    HOLD("Hold", "冻结", "冻结"),
    RELEASE("Release", "解冻", "解冻"),
    ADJUSTQTY("AdjustQty", "数量调整", "数量调整"),
    BORROW("Borrow", "借机(料)出库", "借机(料)出库"),
    GIVEBACK("GiveBack", "还机(料)入库", "还机(料)入库"),
    SCRAP("Scrap", "报废", "报废"),
    INVENTORYINIT("InventoryInit", "库存初始化", "库存初始化");

    /**
     * 枚举值
     */
    private String code;

    /**
     * 枚举名称
     */
    private String enumName;

    /**
     * 枚举实体类属性描述
     */
    private String description;

    OpCodeEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    OpCodeEnum(String code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static LocationEnum getEnumByCode(int enumCode) {
        LocationEnum[] values = LocationEnum.values();
        LocationEnum samplingEnum = null;

        for (LocationEnum value : values) {
            if (value.getCode() == enumCode) {
                samplingEnum = value;
            }
        }
        return samplingEnum;
    }

    public static LocationEnum getEnumByName(String enumName) {
        LocationEnum[] values = LocationEnum.values();
        LocationEnum repairEnum = null;

        for (LocationEnum value : values) {
            if (value.getEnumName() == enumName) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public static Integer getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        LocationEnum[] values = LocationEnum.values();
        for (LocationEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

    public static Map<Integer, String> getEnumByDescription(String enumDescription) {
        Map<Integer, String> enumMap = new HashMap<Integer, String>();
        LocationEnum[] values = LocationEnum.values();
        for (LocationEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        LocationEnum[] values = LocationEnum.values();
        for (LocationEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
}
